<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<%-- <%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> --%>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>挂靠公司详细信息</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div id="pageInTab" class="pageInTab">
			<div tabid="tabA" title="基本信息" id="tabAId">
				<form id="prj_lnk_comp_form">
					<div class="fieldset1 tabel_col clearFix">
						<div class="fieldBox col_50">
							<div class="label">公司名称</div>
							<div class="field">
								<input name="lnkCompNm" id="lnkCompNm" type="text"
									class="ui-textbox" value="${prjLnkComp.lnkCompNm }"
									validate="{required:true}"> <span
									class="requiredSymbol">*</span>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">组织机构代码</div>
							<div class="field">
								<input name="orgCode" id="orgCode" type="text"
									class="ui-textbox" value="${prjLnkComp.orgCode}"
									validate="{required:true}"> <span
									class="requiredSymbol">*</span>
							</div>
						</div>

						<div class="fieldBox col_50">
							<div class="label">公司归属</div>
							<div class="field">
								<select name="ownerCd" id="ownerCd">
									<c:forEach items="${keyValueList}" var="opt">
										<option value="${opt.key}"
											<c:if test="${opt.key==prjLnkComp.ownerCd }">selected="selected"</c:if>>${opt.value}</option>
									</c:forEach>
								</select> <span class="requiredSymbol" isShow="iscar">*</span>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">所在地</div>
							<div class="field">
								<input name="officeAddr" id="officeAddr" type="text"
									isShow="iscar" class="ui-textbox"
									value="${prjLnkComp.officeAddr }"> <span
									class="requiredSymbol" isShow="iscar">*</span>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">主营项目类别</div>
							<div class="field">
								<input name="majorBiz" id="majorBiz" type="text"
									class="ui-textbox" value="${prjLnkComp.majorBiz }">
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">企业类型</div>
							<div class="field">
								<input name="compTyp" id="compTyp" type="text"
									class="ui-textbox" value="${prjLnkComp.compTyp }">
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">营业执照注册号</div>
							<div class="field">
								<input name="bizLicNo" id="bizLicNo" type="text"
									class="ui-textbox" value="${prjLnkComp.bizLicNo }"
									validate="{required:true}"> <span
									class="requiredSymbol" isShow="isother">*</span>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">注册地址</div>
							<div class="field">
								<input name="regAddr" id="regAddr" type="text"
									class="ui-textbox" value="${prjLnkComp.regAddr }">
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">成立日期</div>
							<div class="field">
								<input name="regDt" id="regDt" type="text" isShow="iscar"
									class="ui-datepicker" value="${prjLnkComp.regDt }"> <span
									class="requiredSymbol" isShow="iscar">*</span>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">税务登记号</div>
							<div class="field">
								<input name="taxRegNo" id="taxRegNo" type="text"
									class="ui-textbox" value="${prjLnkComp.taxRegNo }"
									validate="{required:true}"> <span
									class="requiredSymbol">*</span>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">道路运输许可证有效期</div>
							<div class="field">
								<input name="expDt" id="expDt" type="text" isShow="isother"
									class="ui-datepicker" value="${prjLnkComp.expDt }"
									validate="{required:true}"> <span
									class="requiredSymbol" isShow="isother">*</span>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">经营范围</div>
							<div class="field">
								<input name="bizScope" id="bizScope" type="text"
									class="ui-textbox" value="${prjLnkComp.bizScope }">
							</div>
						</div>
						<div class="fieldBox col_50" rlPsnDiv="zk">
							<div class="label">法人代表</div>
							<div class="field">
								<input name="corpRep" id="corpRep" type="text" isShow="iscar"
									class="ui-textbox" value="${prjLnkComp.corpRep }"> <span
									class="requiredSymbol" isShow="iscar">*</span>
							</div>
						</div>
						<div class="fieldBox col_50" rlPsnDiv="zk">
							<div class="label">法人身份证号</div>
							<div class="field">
								<input name="idNo" id="idNo" type="text" class="ui-textbox"
									value="${prjLnkComp.idNo }">
							</div>
						</div>

						<div class="fieldBox col_50">
							<div class="label">现累计挂靠数量</div>
							<div class="field">
								<input name="totLnkQty" id="totLnkQty" type="text"
									class="ui-textbox" value="${prjLnkComp.totLnkQty }">
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">自有车辆备案数量</div>
							<div class="field">
								<input name="ownQty" id="ownQty" type="text" class="ui-textbox"
									value="${prjLnkComp.ownQty }">
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">在我司累积挂靠车辆</div>
							<div class="field">
								<input name="ourTotLnkQyt" id="ourTotLnkQyt" type="text"
									class="ui-textbox" value="${prjLnkComp.ourTotLnkQyt }">
							</div>
						</div>
						<div class="fieldBox col_66_auto">
								<div class="label">区域</div>
								<div class="field">
									<!-- <input name="rgnPrCd" id="rgnPrCd" type="text" class="ui-textbox" value=""> -->
									<jsp:include page="../../system/sysRegion/region.jsp"
										flush="true">
										<jsp:param name="regionShowLvl" value="2" />
									</jsp:include>
									<span class="requiredSymbol">*</span>
								</div>
						</div>
						<%-- <div class="fieldBox col_50" rlPsnDiv="zk">
							<div class="label">实际控制人</div>
							<div class="field">
								<input name="actCtrlNm" id="actCtrlNm" type="text"
									class="ui-textbox" value="${prjLnkComp.actCtrlNm}"
									validate="{required:true}"> <span
									class="requiredSymbol">*</span>
							</div>
						</div> --%>
						<%-- <div class="fieldBox col_50" rlPsnDiv="zk">
							<div class="label">实际控制人手机号码</div>
							<div class="field">
								<input name="actCtrlMp" id="actCtrlMp" type="text"
									class="ui-textbox" value="${prjLnkComp.actCtrlMp }"
									validate="{required:true}"> <span
									class="requiredSymbol">*</span>
							</div>
						</div> --%>
						<%-- <div class="fieldBox col_50" rlPsnDiv="zk">
							<div class="label">联系人</div>
							<div class="field">
								<input name="lnkNm" id="lnkNm" type="text" class="ui-textbox"
									value="${prjLnkComp.lnkNm }">
							</div>
						</div> --%>
						<%-- <div class="fieldBox col_50" rlPsnDiv="zk">
							<div class="label">联系人手机号码</div>
							<div class="field">
								<input name="lnkMp" id="lnkMp" type="text" isShow="iscar"
									class="ui-textbox" value="${prjLnkComp.lnkMp }"> <span
									class="requiredSymbol" isShow="iscar">*</span>
							</div>
						</div> --%>
						<%-- <div class="fieldBox col_50" rlPsnDiv="zk">
							<div class="label">联系人职务</div>
							<div class="field">
								<input name="lnkPost" id="lnkPost" type="text"
									class="ui-textbox" value="${prjLnkComp.lnkPost }">
							</div>
						</div> --%>
						<div class="fieldBox col_100">
							<div class="label">备注</div>
							<div class="field">
								<textarea name="rem" id="rem" rows="4"
									class="ui-textarea l-textarea" style="width: 80%" value="">${prjLnkComp.rem } </textarea>
							</div>
						</div>
					</div>
					<div class="fieldBox col_100" style="display: none;">
						<div class="field">
							<input name="lnkCompId" id="lnkCompId" type="text"
								class="ui-textbox" value="${prjLnkComp.id }">
						</div>
					</div>
					<div class="fieldBox col_100" id="psnDiv" style="display: none">
						<div class="sqPanel">
							<div class="sqPanel_head inL">
								<div class="btnsBox inLC">
									<span id="addBtn" onclick="addBtn();"
										class="sq-button sq-button-round">添加</span>
								</div>

								<span>主要人员信息</span>

								<div class="fieldBox col_100" style="display: none;">
									<div class="field">
										<input name="prelist" id="preList" type="text"
											class="ui-textbox" value="${rlPsnList}">
									</div>
								</div>




							</div>
							<br /> <br />
							<div id="psnGrid">
								<div id="ligergrid_psn" class="sq-grid"></div>
							</div>
						</div>
					</div>

					<div class="fieldset1 tabel_col tabel_col_s clearFix">
						<div class="caption">
							<span class="title">上传附件信息 </span>
						</div>
						<div class="fieldBox col_100" id="fileDetail">
							<div class="label">资料上传</div>
							<div class="field">
								<jsp:include
									page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp"
									flush="true">
									<jsp:param name="filePath" value="lnkcomp" />
								</jsp:include>
								<input name="lnkCompId" id="lnkCompId" type="hidden"
									class="ui-textbox" value="${prjLnkComp.id }">
							</div>
						</div>

						<div class="fieldBox col_100" id="fileModify">
							<div class="label">资料</div>
							<div class="field">
								<jsp:include
									page="../../system/sysUlFilesRec/sysUlFileRecList.jsp"
									flush="true">
									<jsp:param name="pkId" value="${prjLnkComp.id }" />
									<jsp:param name="tabNm" value="PRJ_LNK_COMP" />
								</jsp:include>
							</div>
						</div>
					</div>

					<div class="btnsBox">
						<span id="prj_lnk_comp_add_btn_id"
							class="sq-button sq-button-round" onclick="save();"> <!-- <i class="sqBtnIco_10"></i> -->保存
						</span> <span id="prj_lnk_comp__cancel_btn_id"
							class="sq-button sq-button-round" onclick="cancelBtn();">
							<!-- <i class="sqBtnIco_14"></i> -->取消
						</span>
					</div>
				</form>
			</div>
			<div tabid="tabB" title="相关项目" id="tabBId">
				<iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
			</div>
			<div tabid="tabC" title="备案账号" id="tabCId">
				<iframe frameborder="0" name="tabC" id="tabC" src=""></iframe>
			</div>
			<div tabid="tabD" title="敞口历史" id="tabDId">
				<iframe frameborder="0" name="tabD" id="tabD" src=""></iframe>
			</div>
			<div tabid="tabE" title="人工干预" id="tabEId">
				<iframe frameborder="0" name="tabE" id="tabE" src=""></iframe>
			</div>
		</div>
	</div>
	</div>

	<script type="text/javascript">

    var BuOrgCd = '${BuOrgCd}';
    var audStsCd = '${audStsCd}';
    var rlPsnGrid;
    var rlPsnList = null;
    var isFlow = '${isFlow}';
    var auditStatus ='${auditStatus}';
    if ('${rlPsnList}') {
        rlPsnList =${rlPsnList};
    }
    var certTypCdList =${certTypCdList};
    var rlRsnTypListJSON =${rlRsnTypListJSON};
    var rlRsnTypList = [];
    if ('${rlRsnTypList}') {
        rlRsnTypList = JSON.parse('${rlRsnTypList}');
    }
    var pageInApp = {
        flag: true
    };
    $(function () {
        initStyle();
        initData();
        var lnkCompId = $("#lnkCompId").val();
        if (BuOrgCd == "00000005") {
            initRlPsnCarGrid(rlPsnList);
        } else {
            initRlPsnGrid(rlPsnList);
        }
     /*    初始化关联人员变更信息 */

    });

    function initStyle() {
        if (BuOrgCd == "00000005") {
            $("span[isShow='iscar']").each(function () {
                $("input[isShow='iscar']").each(function () {
                    $(this).attr("validate", "{required:true}");
                });
                $(this).show();
            });
            $("span[isShow='isother']").each(function () {
                $("input[isShow='isother']").each(function () {
                    $(this).attr("validate", "");
                });
                $(this).hide();
            });
            $("div[rlPsnDiv='zk'] div input").each(function () {
                $(this).attr("validate", "");
            });
            $("div[rlPsnDiv='zk']").each(function () {
                $(this).hide();
            });
        } else {
            $("span[isShow='iscar']").each(function () {
                $("input[isShow='iscar']").each(function () {
                    $(this).attr("validate", "");
                });
                $(this).hide();
            });
            $("span[isShow='isother']").each(function () {
                $("input[isShow='isother']").each(function () {
                    $(this).attr("validate", "{required:true}");
                });
                $(this).show();
            });
        }
        if (BuOrgCd != "00000005") {
            if (audStsCd == FlowConstant.FLOW_CHECK_STATE_PASS) {
                 $("#prj_lnk_comp_form div div div input").each(function () {
                   /*  $(this).attr("readonly", "readonly"); */
                });
                // $("#fileDetail").hide();
            } else {
                $("div[rlPsnDiv='zk']").each(function () {
                    $(this).hide();
                });
            }
            $("div[rlPsnDiv='zk'] div input").each(function () {
                $(this).attr("validate", "");
            });
            var compId = $("#lnkCompId").val();
        }
        if(BuOrgCd==ProjectConstant.CODE_BU_ORG_CD_XNY){
        	$("#psnDiv").hide();
        }else{
            $("#psnDiv").show();
        }


    }

    var pageInTab = null;
    var loadedTabs = []

    //初始化数据
    function initData() {
    	setFormatRgnValue()
        setFormatDateValue();
        $("#prj_lnk_comp_form").ligerForm({
            validate: true,
            onAfterSetFields: function () {
            	this.CACHED_INIT_VALUES = getFormValues(this.id)
            }
        });
        var id = $("#lnkCompId").val();
        if (!id) {
            var baseForm1 = liger.get("prj_lnk_comp_form");
            baseForm1.setData({
                ownerCd: ProjectConstant.CODE_OWNER_CD
            });
            //设置公司归属默认为第三方
        }
        initTab();
        if (BuOrgCd != "00000005") {
        	if(auditStatus == '1'){
        		liger.get("lnkCompNm").setDisabled(true);
                liger.get("orgCode").setDisabled(true);
                liger.get("bizLicNo").setDisabled(true);
                liger.get("taxRegNo").setDisabled(true);
                liger.get("expDt").setDisabled(true);
        	}
            if (audStsCd == FlowConstant.FLOW_CHECK_STATE_PASS) {
            	 /* liger.get("lnkCompNm").setDisabled(true);
                 liger.get("orgCode").setDisabled(true);
                 liger.get("bizLicNo").setDisabled(true);
                 liger.get("taxRegNo").setDisabled(true);
                 liger.get("expDt").setDisabled(true); */
            }
            //pageInTab.removeTabItem("tabC");
        } else {
            pageInTab.removeTabItem("tabD");
        }

    }

    //初始化Tab
    function initTab() {
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onBeforeSelectTabItem: function (tabid) {
                var lnkCompId = $("#lnkCompId").val();
                if (tabid != "tabA") {
                    if (lnkCompId == null || lnkCompId == '') {
                        top.$.ligerDialog.SQalert({content: LogUtils.LOG_LNK_COMP_SELECT_BEFORE, SQ_type: "warning"});
                        return false;
                    }
                }
            },
            onAfterSelectTabItem: function (tabid) {
                //   if (loadedTabs.indexOf(tabid)<0) {
                var lnkCompId = $("#lnkCompId").val();
                if (tabid != "tabA") {
                    if (lnkCompId == null || lnkCompId == '') {
                        top.$.ligerDialog.SQalert({content: LogUtils.LOG_LNK_COMP_SELECT_BEFORE, SQ_type: "warning"});
                        return false; //验证不通过，不执行以下代码
                    }
                }
                loadedTabs.push(tabid);
                switch (tabid) {
                    case "tabB":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjbscinfo/toPrjBscInfoListPage.do?lnkCompId=" + lnkCompId + "&&isLnkCompFlag=1");
                        break;
                    case "tabC":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjLnkCompBkAcc/toListPage.do?compId=" + lnkCompId);
                        break;
                    case "tabD":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjLnkCompCrLim/toListPage.do?compId=" + lnkCompId);
                        break;
					case "tabE":
						pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstManualRelation/toListPage.do?Id=" + lnkCompId +"&useType=3&cstType=2");
						break;
                }
                //     };
                SetIframe_height();
            }
        });

        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    };

    function setFormatRgnValue(){
    	rgnPrCd = '${prjLnkComp.rgnPrCd}';
        rgnCyCd = '${prjLnkComp.rgnCyCd}';
        //alert(rgnPrCd)
        setRgnProvCdUpdataValue(rgnPrCd);
    	setRgnCityCdUpdataValue(rgnCyCd);
    	setRegionSelectDataChange();
    }
    //设置日期值
    function setFormatDateValue() {
        var regDt = $("#regDt").val();
        var expDt = $("#expDt").val();
        if (expDt) {
            var expDate = DateUtils.formatDate(new Date(expDt), DateUtils.YYYY_MM_DD);
            $("#expDt").val(expDate);//道路运输许可证有效期
        }
        if (regDt) {
            var regDate = DateUtils.formatDate(new Date(regDt), DateUtils.YYYY_MM_DD);
            $("#regDt").val(regDate);//注册日期
        }

    }

    //检查是否重名
    function checkPrjLnkCompNm() {
        var flag = false;
        var lnkCompNm = $("#lnkCompNm").val();
        var url = '<%=path%>/project/prjlnkcomp/checkPrjLnkCompNm.do';
        var data = {};
        data.lnkCompNm = lnkCompNm;
        if (lnkCompNm) {
            $.ajax({
                type: 'get',
                dataType: 'json',
                data: data,
                url: url,
                success: function (msg) {
                    if (msg.success == 1) {
                        if (msg.data) {
                            top.$.ligerDialog.SQalert({content: "该挂靠公司已经存在", SQ_type: "error"});
                            flag = true;
                        }
                    }
                }
            });
        }
        return flag;
    }

    //取消
    function cancelBtn() {
        var TAB = top.mainApp.parentTab;
        var currentTabid = TAB.getSelectedTabItemID();
        top.tab.removeTabItem(currentTabid);
    }
  /*   var compareResult1 = compareGridData('ligergrid_psn', ['rlNm', 'rlTypCdNm', 'certNo', 'tel'], 4);
    var compareResult2 = compareFormValues('prj_lnk_comp_form', ['lnkCompNm', 'orgCode', 'bizLicNo', 'taxRegNo', 'expDt']);
    var compareResult = !compareResult1 || !compareResult2 ? false : true; */
    function save1() {
    	var compareResult1 = compareGridData('ligergrid_psn', ['rlNm', 'rlTypCdNm', 'certNo', 'tel'], 4);
        var compareResult2 = compareFormValues('prj_lnk_comp_form', ['lnkCompNm', 'orgCode', 'bizLicNo', 'taxRegNo', 'expDt']);
        var compareResult = !compareResult1 || !compareResult2 ? false : true;
    	if(compareResult==true){
    		var ligerForm = liger.get("prj_lnk_comp_form");
            if (!ligerForm.valid()) {
                top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            var rlPsnData = rlPsnGrid.getData();
            var lnkCompNm = $("#lnkCompNm").val();
            var lnkCompId = $("#lnkCompId").val();
            if (lnkCompId) {
                var data = ligerForm.getData();
                data["regDt"] = $("#regDt").val();
                data["expDt"] = $("#expDt").val();
                //event.preventDefault();

                var fileParams = getUploadResultParams();//获取附件上传的信息
                data["fileParams"] = JSON.stringify(fileParams);
                //  if(BuOrgCd!=ProjectConstant.CODE_BU_ORG_CD_CAR){
                var isValid = SQ.validGrid('ligergrid_psn');
                if (isValid == false) {
                    UIUtils.alertError("请正确填写！");
                    return false;
                }
                ;
                data["rlPsnList"] = JSON.stringify(rlPsnData);
                //  }

               var url = '<%=path%>/project/prjlnkcomp/addPrjLnkComp.do';
                var lnkCompId = $("#lnkCompId").val();
                data["lnkCompId"] = lnkCompId;

                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: data,
                    url: url,
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            if (!isFlow) {
                                var TAB = top.mainApp.parentTab;
                                var currentTabid = TAB.getSelectedTabItemID();
                                var currFrameElement = top.$("#" + currentTabid).get(0);
                                var callback = currFrameElement.W2W.callback;
                                callback();
                                top.tab.removeTabItem(currentTabid);
                            }
                        } else {
                            top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });
            } else {
                var url = '<%=path%>/project/prjlnkcomp/checkPrjLnkCompNm.do';
                var data = {};
                data.lnkCompNm = lnkCompNm;
                $.ajax({
                    type: 'get',
                    dataType: 'json',
                    data: data,
                    url: url,
                    success: function (msg) {
                        if (msg.success == 1) {
                            if (msg.data) {
                                top.$.ligerDialog.SQalert({content: "该挂靠公司已经存在", SQ_type: "error"});
                                return false;
                            }
                        } else {
                            var data = ligerForm.getData();
                            data["regDt"] = $("#regDt").val();
                            data["expDt"] = $("#expDt").val();

                            var fileParams = getUploadResultParams();//获取附件上传的信息
                            data["fileParams"] = JSON.stringify(fileParams);
                            //   if(BuOrgCd==ProjectConstant.CODE_BU_ORG_CD_ZK){
                            var isValid = SQ.validGrid('ligergrid_psn');
                            if (isValid == false) {
                                UIUtils.alertError("请正确填写！");
                                return false;
                            }
                            ;
                            data["rlPsnList"] = JSON.stringify(rlPsnData);
                            //  }
                            var url = '<%=path%>/project/prjlnkcomp/addPrjLnkComp.do';
                            var lnkCompId = $("#lnkCompId").val();
                            data["lnkCompId"] = lnkCompId;
                            var wait_dialog;
                            $.ajax({
                                type: 'post',
                                dataType: 'json',
                                data: data,
                                url: url,
                                beforeSend: function () {
                                    wait_dialog = $.ligerDialog.SQalert({
                                        content: LogUtils.LOG_CMM_DATA_LOADING,
                                        SQ_type: "waitting"
                                    });
                                },
                                success: function (msg) {
                                    wait_dialog.close();
                                    if (msg.success == 1) {
                                        $("#lnkCompId").val(msg.data);
                                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                                        var TAB = top.mainApp.parentTab;
                                        var currentTabid = TAB.getSelectedTabItemID();
                                        var currFrameElement = top.$("#" + currentTabid).get(0);
                                        var callback = currFrameElement.W2W.callback;
                                        callback();
                                        top.tab.removeTabItem(currentTabid);

                                    } else {
                                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                                    }
                                }
                            });
                        }
                    }
                });
            }
    	}else{ // 有挂靠公司id 走流程 ，无走添加
    		 if (lnkCompId) {
    			 startSqlAdmissionFlow();
    		 } else {
                 var url = '<%=path%>/project/prjlnkcomp/checkPrjLnkCompNm.do';
                 var data = {};
                 data.lnkCompNm = lnkCompNm;
                 $.ajax({
                     type: 'get',
                     dataType: 'json',
                     data: data,
                     url: url,
                     success: function (msg) {
                         if (msg.success == 1) {
                             if (msg.data) {
                                 top.$.ligerDialog.SQalert({content: "该挂靠公司已经存在", SQ_type: "error"});
                                 return false;
                             }
                         }else {
                             var data = ligerForm.getData();
                             data["regDt"] = $("#regDt").val();
                             data["expDt"] = $("#expDt").val();

                             var fileParams = getUploadResultParams();//获取附件上传的信息
                             data["fileParams"] = JSON.stringify(fileParams);
                             //   if(BuOrgCd==ProjectConstant.CODE_BU_ORG_CD_ZK){
                             var isValid = SQ.validGrid('ligergrid_psn');
                             if (isValid == false) {
                                 UIUtils.alertError("请正确填写！");
                                 return false;
                             }
                             ;
                             data["rlPsnList"] = JSON.stringify(rlPsnData);
                             //  }
                             var url = '<%=path%>/project/prjlnkcomp/addPrjLnkComp.do';
                             var lnkCompId = $("#lnkCompId").val();
                             data["lnkCompId"] = lnkCompId;
                             var wait_dialog;
                             $.ajax({
                                 type: 'post',
                                 dataType: 'json',
                                 data: data,
                                 url: url,
                                 beforeSend: function () {
                                     wait_dialog = $.ligerDialog.SQalert({
                                         content: LogUtils.LOG_CMM_DATA_LOADING,
                                         SQ_type: "waitting"
                                     });
                                 },
                                 success: function (msg) {
                                     wait_dialog.close();
                                     if (msg.success == 1) {
                                         $("#lnkCompId").val(msg.data);
                                         top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                                         var TAB = top.mainApp.parentTab;
                                         var currentTabid = TAB.getSelectedTabItemID();
                                         var currFrameElement = top.$("#" + currentTabid).get(0);
                                         var callback = currFrameElement.W2W.callback;
                                         callback();
                                         top.tab.removeTabItem(currentTabid);

                                     } else {
                                         top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                                     }
                                 }
                             });
                         }
                     }
                 });
             }

    	}
    }

    function save() {
        var ligerForm = liger.get("prj_lnk_comp_form");
        if (!ligerForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var rlPsnData = rlPsnGrid.getData();
        var lnkCompNm = $("#lnkCompNm").val();
        var lnkCompId = $("#lnkCompId").val();
        var rgnPrCd = getRgnProvCd();//获取省代码
    	var rgnCyCd = getRgnCityCd();//获取市代码
        if (lnkCompId) {
            var data = ligerForm.getData();
            data["regDt"] = $("#regDt").val();
            data["expDt"] = $("#expDt").val();
            data["rgnPrCd"] = rgnPrCd;//获取省代码
    		data["rgnCyCd"] = rgnCyCd;//获取市代码
            //event.preventDefault();

            var fileParams = getUploadResultParams();//获取附件上传的信息
            data["fileParams"] = JSON.stringify(fileParams);
            //  if(BuOrgCd!=ProjectConstant.CODE_BU_ORG_CD_CAR){
            var isValid = SQ.validGrid('ligergrid_psn');
            if (isValid == false) {
                UIUtils.alertError("请正确填写！");
                return false;
            }
            ;
            data["rlPsnList"] = JSON.stringify(rlPsnData);
            //  }
           <%--  var url = '<%=path%>/project/prjlnkcomp/addPrjLnkComp.do'; --%>
            var lnkCompId = $("#lnkCompId").val();
            data["lnkCompId"] = lnkCompId;

            var wait_dialog;

            //判断数据是否便变化
            var compareResult1 = compareGridData('ligergrid_psn', ['rlNm', 'rlTypCdNm', 'certNo', 'tel'], 4);
            var compareResult2 = compareFormValues('prj_lnk_comp_form', ['lnkCompNm', 'orgCode', 'bizLicNo', 'taxRegNo', 'expDt']);
            var compareResult = !compareResult1 || !compareResult2 ? false : true;
        	if(compareResult==true){
        		$.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: data,
                    url: '<%=path%>/project/prjlnkcomp/addPrjLnkComp.do',
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            if (!isFlow) {
                                var TAB = top.mainApp.parentTab;
                                var currentTabid = TAB.getSelectedTabItemID();
                                var currFrameElement = top.$("#" + currentTabid).get(0);
                                var callback = currFrameElement.W2W.callback;
                                callback();
                                top.tab.removeTabItem(currentTabid);
                            }
                        } else {
                            top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });

        	}else{
        		startSqlAdmissionFlow();
        	}

        } else {
            var url = '<%=path%>/project/prjlnkcomp/checkPrjLnkCompNm.do';
            var data = {};
            data.lnkCompNm = lnkCompNm;
            $.ajax({
                type: 'get',
                dataType: 'json',
                data: data,
                url: url,
                success: function (msg) {
                    if (msg.success == 1) {
                        if (msg.data) {
                            top.$.ligerDialog.SQalert({content: "该挂靠公司已经存在", SQ_type: "error"});
                            return false;
                        }
                    } else {
                        var data = ligerForm.getData();
                        data["regDt"] = $("#regDt").val();
                        data["expDt"] = $("#expDt").val();

                        var fileParams = getUploadResultParams();//获取附件上传的信息
                        data["fileParams"] = JSON.stringify(fileParams);
                        //   if(BuOrgCd==ProjectConstant.CODE_BU_ORG_CD_ZK){
                        var isValid = SQ.validGrid('ligergrid_psn');
                        if (isValid == false) {
                            UIUtils.alertError("请正确填写！");
                            return false;
                        }
                        data["rlPsnList"] = JSON.stringify(rlPsnData);
                        //  }
                        var url = '<%=path%>/project/prjlnkcomp/addPrjLnkComp.do';
                        var lnkCompId = $("#lnkCompId").val();
                        data["lnkCompId"] = lnkCompId;
                        var wait_dialog;
                        $.ajax({
                            type: 'post',
                            dataType: 'json',
                            data: data,
                            url: url,
                            beforeSend: function () {
                                wait_dialog = $.ligerDialog.SQalert({
                                    content: LogUtils.LOG_CMM_DATA_LOADING,
                                    SQ_type: "waitting"
                                });
                            },
                            success: function (msg) {
                                wait_dialog.close();
                                if (msg.success == 1) {
                                    $("#lnkCompId").val(msg.data);
                                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                                    var TAB = top.mainApp.parentTab;
                                    var currentTabid = TAB.getSelectedTabItemID();
                                    var currFrameElement = top.$("#" + currentTabid).get(0);
                                    var callback = currFrameElement.W2W.callback;
                                    callback();
                                    top.tab.removeTabItem(currentTabid);

                                } else {
                                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                                }
                            }
                        });
                    }
                }
            });

        }

    }


    //发起审核流程
    function startSqlAdmissionFlow() {
        var modelTyp = FlowConstant.FLOW_MODEL_TYP_LNK_CHG;//流程业务分类-供应商准入
        if (StringUtils.isEmpty(modelTyp)) {
            return;
        }
        var flowDialog = $.ligerDialog.SQopen({
            url: '<%=path%>/flow/flow/toForStartListPage.do?modelTyp=' + modelTyp,
            width: 700,
            height: 400,
            title: '请选择要发起的流程',
            buttons: [{
                text: "确定", type: 'ok', cls: 'l-dialog-btn-ok',
                onclick: function (item, Dialog) {
                    if (Dialog.onOk) {
                        $.ligerDialog.SQconfirm('是否确定发起变更流程?', function (flag) {
                            if (flag == false) {
                                return;
                            } else {
                                Dialog.onOk();
                            }
                        })
                    }
                }
            }, {
                text: "取消", type: 'cancel', cls: 'l-dialog-btn-no',
                onclick: function (item, Dialog) {
                    if (Dialog.onCancel) Dialog.onCancel();
                }
            }
            ],
            onClose: function () {
                var json = flowDialog._DATA;
                if (!json) {
                    return;
                }
                saveApplyInfo(json);
            }
        });
    }

    /**
     * 调用挂靠公司保存事件
     * @param strJsons
     * @returns {boolean}
     */
    function saveApplyInfo(strJsons) {

        var ligerForm = liger.get("prj_lnk_comp_form");
        if (!ligerForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var rlPsnData = rlPsnGrid.getData();
        var lnkCompNm = $("#lnkCompNm").val();
        var lnkCompId = $("#lnkCompId").val();
        var url = '<%=path%>/project/prjlnkcomp/checkPrjLnkCompNm.do';
        var data = {};
        data.lnkCompNm = lnkCompNm;

        $.ajax({
            type: 'get',
            dataType: 'json',
            data: data,
            url: url,
            success: function (msg) {
                    var data = ligerForm.getData();
                    data["regDt"] = $("#regDt").val();
                    data["expDt"] = $("#expDt").val();

                    if (StringUtils.isNotEmpty(strJsons)) {
                        data["procDefKey"] = strJsons.procDefKey;
                        data["procDefId"] = strJsons.procDefId;
                        data["procNo"] = strJsons.procNo;
                    }

                    var fileParams = getUploadResultParams();//获取附件上传的信息
                    data["fileParams"] = JSON.stringify(fileParams);
                    //   if(BuOrgCd==ProjectConstant.CODE_BU_ORG_CD_ZK){
                    var isValid = SQ.validGrid('ligergrid_psn');
                    if (isValid == false) {
                        UIUtils.alertError("请正确填写！");
                        return false;
                    }
                    ;
                    data["rlPsnList"] = JSON.stringify(rlPsnData);
                    //  }
                    var url = '<%=path%>/ project/prjLnkCompApply/addPrjLnkComp.do?flag='+'uflag';
                    var lnkCompId = $("#lnkCompId").val();
                    data["lnkCompId"] = lnkCompId;
                    var wait_dialog;
                    $.ajax({
                        type: 'post',
                        dataType: 'json',
                        data: data,
                        url: url,
                        beforeSend: function () {
                            wait_dialog = $.ligerDialog.SQalert({
                                content: LogUtils.LOG_CMM_DATA_LOADING,
                                SQ_type: "waitting"
                            });
                        },
                        success: function (msg) {
                            wait_dialog.close();
                            if (msg.success == 1) {
                                var url = '<%=path%>/flow/flow/getFlowNextAssigne.do?key=' + msg.info;
                                FlowUtils.alertNextFlowAssign(url);
                                setTimeout(function () {
									$("#lnkCompId").val(msg.data);
									var TAB = top.mainApp.parentTab;
									var currentTabid = TAB.getSelectedTabItemID();
									var currFrameElement = top.$("#" + currentTabid).get(0);
									var callback = currFrameElement.W2W.callback;
									callback();
									top.tab.removeTabItem(currentTabid);
                                }, 11000);
                            } else {
                                top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                            }
                        }
                    });



            }
        });
    }
<%--     function saveApplyInfo(strJsons) {

        var ligerForm = liger.get("prj_lnk_comp_form");
        if (!ligerForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var rlPsnData = rlPsnGrid.getData();
        var lnkCompNm = $("#lnkCompNm").val();
        var lnkCompId = $("#lnkCompId").val();
        var url = '<%=path%>/project/prjlnkcomp/checkPrjLnkCompNm.do';
        var data = {};
        data.lnkCompNm = lnkCompNm;



        $.ajax({
            type: 'get',
            dataType: 'json',
            data: data,
            url: url,
            success: function (msg) {
            	 /* if (StringUtils.isNotEmpty(strJsons)) {
                     parent.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                     Remove_navTab();
                 }  */

                if (msg.success == 1) {
                    if (msg.data) {
                        top.$.ligerDialog.SQalert({content: "挂靠公司已存在", SQ_type: "error"});
                        return false;
                    }
                }else {
                    var data = ligerForm.getData();
                    data["regDt"] = $("#regDt").val();
                    data["expDt"] = $("#expDt").val();

                    if (StringUtils.isNotEmpty(strJsons)) {
                        data["procDefKey"] = strJsons.procDefKey;
                        data["procDefId"] = strJsons.procDefId;
                        data["procNo"] = strJsons.procNo;
                    }

                    var fileParams = getUploadResultParams();//获取附件上传的信息
                    data["fileParams"] = JSON.stringify(fileParams);
                    //   if(BuOrgCd==ProjectConstant.CODE_BU_ORG_CD_ZK){
                    var isValid = SQ.validGrid('ligergrid_psn');
                    if (isValid == false) {
                        UIUtils.alertError("请正确填写！");
                        return false;
                    }
                    ;
                    data["rlPsnList"] = JSON.stringify(rlPsnData);
                    //  }
                    var url = '<%=path%>/ project/prjLnkCompApply/addPrjLnkComp.do?flag='+'uflag';
                    var lnkCompId = $("#lnkCompId").val();
                    data["lnkCompId"] = lnkCompId;
                    var wait_dialog;
                    $.ajax({
                        type: 'post',
                        dataType: 'json',
                        data: data,
                        url: url,
                        beforeSend: function () {
                            wait_dialog = $.ligerDialog.SQalert({
                                content: LogUtils.LOG_CMM_DATA_LOADING,
                                SQ_type: "waitting"
                            });
                        },
                        success: function (msg) {
                            wait_dialog.close();
                            if (msg.success == 1) {
                                $("#lnkCompId").val(msg.data);
                                UIUtils.alertSuccessHold1(msg.info);
                                var TAB = top.mainApp.parentTab;
                                var currentTabid = TAB.getSelectedTabItemID();
                                var currFrameElement = top.$("#" + currentTabid).get(0);
                                var callback = currFrameElement.W2W.callback;
                                callback();
                                top.tab.removeTabItem(currentTabid);

                            } else {
                                top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                            }
                        }
                    });
                }
            }
        });
    } --%>

    function initRlPsnGrid(data) {
        rlPsnGrid = $("#ligergrid_psn").ligerGrid({
            data: data,
            columns: [
                {
                    display: '姓名(<span class="c_red">*</span>)', name: 'rlNm', minWidth: 60, editor: {type: 'text'},
                    validate: function (value) {
                        if (StringUtils.isEmpty(value)) return "此项为必填项！";
                    }
                },
                {
                    display: '联系人类型(<span class="c_red">*</span>)', name: 'rlTypCdNm', minWidth: 60,
                    editor: {
                        type: 'select',
                        data: rlRsnTypListJSON,
                        valueField: 'key',
                        textField: 'value'
                    },
                    valueField: 'rlTypCd',
                    textField: 'rlTypCdNm',
                    render: function (item) {
                        return item.rlTypCdNm;
                    },
                    validate: function (value) {
                        if (StringUtils.isEmpty(value)) return "此项为必填项！";
                    }
                },
                {display: '股比',name:'stockRatio',width:100},
                {
                    display: '证件类型(<span class="c_red">*</span>)', name: 'certTypCdNm', minWidth: 60,
                    editor: {
                        type: 'select',
                        data: certTypCdList,
                        valueField: 'key',
                        textField: 'value'
                    },
                    valueField: 'certTypCd',
                    textField: 'certTypCdNm',
                    render: function (item) {
                        return item.certTypCdNm;
                    },
                    validate: function (value) {
                        if (StringUtils.isEmpty(value)) return "此项为必填项！";
                    }
                },
                {
                    display: '证件号码(<span class="c_red">*</span>)',
                    name: 'certNo',
                    width: 140,
                    align: 'left',
                    editor: {type: 'text'},
                    validate: function (value) {
                        if (StringUtils.isEmpty(value)) return "此项为必填项！";
                    }
                },
                {
                    display: '联系电话(<span class="c_red">*</span>)',
                    name: 'tel',
                    width: 100,
                    align: 'left',
                    editor: {type: 'text'},
                    validate: function (value) {
                        if (StringUtils.isEmpty(value)) return "此项为必填项！";
                    }
                },
                {display: '备注', name: 'rlRem', minWidth: 140, editor: {type: 'text'}},
                { display: '工商信息校验结果', name: 'busInfoVerify', minWidth: 150,
 	            	render: function(rowdata, rowindex, value){
	 	            		if(rowdata.busInfoVerify == 1){
	 	            			return "一致" ;
	 	            		}else if(rowdata.busInfoVerify == -1){
	 	            			return "不一致";
	 	            		}else if(rowdata.busInfoVerify == 0){
	 	            			return "未查得";
	 	            		}else{
	 	            			return "";
	 	            		}
 	            	}
 	           	},

 	           	{ display: '三要素校验结果1', name: 'pyPerVerify', minWidth: 150,
 	            	render: function(rowdata, rowindex, value){
	 	            		if(rowdata.pyPerVerify == 1){
	 	            			return "一致" ;
	 	            		}else if(rowdata.pyPerVerify == -1){
	 	            			return "不一致";
	 	            		}else if(rowdata.pyPerVerify == 0){
	 	            			return "未查得";
	 	            		}else{
	 	            			return "";
	 	            		}
 	            	}
 	           	},

 	           	{ display: '三要素校验结果2', name: 'tdPerVerify', minWidth: 150,
	 	           	render: function(rowdata, rowindex, value){
			 	           	if(rowdata.tdPerVerify == 1){
	 	            			return "一致" ;
	 	            		}else if(rowdata.tdPerVerify == -1){
	 	            			return "不一致";
	 	            		}else if(rowdata.tdPerVerify == 0){
	 	            			return "未查得";
	 	            		}else{
	 	            			return "";
	 	            		}
	 	           	}
 	           	},

 	           	{ display: '三要素校验结果3', name: 'brPerVerify', minWidth: 150,
 	            	render: function(rowdata, rowindex, value){
	 	            		if(rowdata.brPerVerify == 1){
	 	            			return "一致" ;
	 	            		}else if(rowdata.brPerVerify == -1){
	 	            			return "不一致";
	 	            		}else if(rowdata.brPerVerify == 0){
	 	            			return "未查得";
	 	            		}else{
	 	            			return "";
	 	            		}
 	            	}
 	           	},
                getOptColumn()
            ],
            onBeforeSubmitEdit: function (e) {//重新赋值,要不然选中后离开会把key显示在前端
                if (e.selected && e.column.columnname == "certTypCdNm") {
                    e.record.certTypCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.certTypCd = e.record.certTypCdId;
                }
                if (e.selected && e.column.columnname == "rlTypCdNm") {
                    e.record.rlTypCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.rlTypCd = e.record.rlTypCdId;
                }
            },
            onBeforeEdit: function (e) {
            	e.lastValue = e.value;
                e.index = e.rowindex;
                e.column.editor.readonly = false;
                var colNanme = e.column.columnname; //auditStatus
                if (e.record.isDefault == 1) {
                   if(auditStatus == '1'){
                	   if (colNanme == "rlTypCdNm"  || colNanme == "certTypCdNm" ||colNanme == "rlNm"
                		   || colNanme == "certNo" || colNanme == "tel") {
                           e.column.editor.readonly = true;
                       }
                    }else{
                    	if (colNanme == "rlTypCdNm"  || colNanme == "certTypCdNm") {
                            e.column.editor.readonly = true;
                        }
                    }
                }
            },

            pageSize: 100,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            heightDiff: -2,
            checkbox: false,
            enabledEdit: true,
            allowUnSelectRow: true,
            alternatingRow: false,
            rownumbers: true,
            enabledSort: false,
            usePagerOnLessPagesize: false,
            onAfterShowData: function (currentData) {
            	this.CACHED_DATA = JSON.parse(JSON.stringify(currentData))
            }
        });
        rlPsnGrid.setHeight(200);
    }

    function initRlPsnCarGrid(data) {
        rlPsnGrid = $("#ligergrid_psn").ligerGrid({
            data: data,
            columns: [
                {display: '姓名(<span class="c_red">*</span>)', name: 'rlNm', minWidth: 60, editor: {type: 'text'}},
                {
                    display: '联系人类型(<span class="c_red">*</span>)', name: 'rlTypCdNm', minWidth: 60,
                    editor: {
                        type: 'select',
                        data: rlRsnTypListJSON,
                        valueField: 'key',
                        textField: 'value'
                    },
                    valueField: 'rlTypCd',
                    textField: 'rlTypCdNm',
                    render: function (item) {
                        return item.rlTypCdNm;
                    },
                    validate: function (value) {
                        if (value == '' || value == undefined) return "此项为必填项！";
                    }
                },
                {display: '股比',name:'stockRatio',width:100},
                {
                    display: '证件类型(<span class="c_red">*</span>)', name: 'certTypCdNm', minWidth: 60,
                    editor: {
                        type: 'select',
                        data: certTypCdList,
                        valueField: 'key',
                        textField: 'value'
                    },
                    valueField: 'certTypCd',
                    textField: 'certTypCdNm',
                    render: function (item) {
                        return item.certTypCdNm;
                    },
                    validate: function (value) {
                        if (value == '' || value == undefined) return "此项为必填项！";
                    }
                },
                {
                    display: '证件号码(<span class="c_red">*</span>)',
                    name: 'certNo',
                    width: 140,
                    align: 'left',
                    editor: {type: 'text'}
                },
                {
                    display: '联系电话(<span class="c_red">*</span>)',
                    name: 'tel',
                    width: 100,
                    align: 'left',
                    editor: {type: 'text'},
                    validate: function (value) {
                        if (value == '' || value == undefined) return "此项为必填项！";
                    }
                },
                {display: '备注', name: 'rlRem', minWidth: 140, editor: {type: 'text'}},
                { display: '工商信息校验结果', name: 'busInfoVerify', minWidth: 150,
 	            	render: function(rowdata, rowindex, value){
	 	            		if(rowdata.busInfoVerify == 1){
	 	            			return "一致" ;
	 	            		}else if(rowdata.busInfoVerify == -1){
	 	            			return "不一致";
	 	            		}else if(rowdata.busInfoVerify == 0){
	 	            			return "未查得";
	 	            		}else{
	 	            			return "";
	 	            		}
 	            	}
 	           	},

 	           	{ display: '三要素校验结果1', name: 'pyPerVerify', minWidth: 150,
 	            	render: function(rowdata, rowindex, value){
	 	            		if(rowdata.pyPerVerify == 1){
	 	            			return "一致" ;
	 	            		}else if(rowdata.pyPerVerify == -1){
	 	            			return "不一致";
	 	            		}else if(rowdata.pyPerVerify == 0){
	 	            			return "未查得";
	 	            		}else{
	 	            			return "";
	 	            		}
 	            	}
 	           	},

 	           	{ display: '三要素校验结果2', name: 'tdPerVerify', minWidth: 150,
	 	           	render: function(rowdata, rowindex, value){
			 	           	if(rowdata.tdPerVerify == 1){
	 	            			return "一致" ;
	 	            		}else if(rowdata.tdPerVerify == -1){
	 	            			return "不一致";
	 	            		}else if(rowdata.tdPerVerify == 0){
	 	            			return "未查得";
	 	            		}else{
	 	            			return "";
	 	            		}
	 	           	}
 	           	},

 	           	{ display: '三要素校验结果3', name: 'brPerVerify', minWidth: 150,
 	            	render: function(rowdata, rowindex, value){
	 	            		if(rowdata.brPerVerify == 1){
	 	            			return "一致" ;
	 	            		}else if(rowdata.brPerVerify == -1){
	 	            			return "不一致";
	 	            		}else if(rowdata.brPerVerify == 0){
	 	            			return "未查得";
	 	            		}else{
	 	            			return "";
	 	            		}
 	            	}
 	           	},
                getOptColumn()
            ],
            onBeforeSubmitEdit: function (e) {//重新赋值,要不然选中后离开会把key显示在前端
                if (e.selected && e.column.columnname == "certTypCdNm") {
                    e.record.certTypCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.certTypCd = e.record.certTypCdId;
                }
                if (e.selected && e.column.columnname == "rlTypCdNm") {
                    e.record.rlTypCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.rlTypCd = e.record.rlTypCdId;
                }
            },
            onBeforeEdit: function (e) {
                e.lastValue = e.value;
                e.index = e.rowindex;
                e.column.editor.readonly = false;
                var colNanme = e.column.columnname;
                if (e.record.isSysDef == 1) {
                    if (colNanme == "rlTypCdNm") {
                        e.column.editor.readonly = true;
                    }
                }
            },
            pageSize: 100,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            heightDiff: -2,
            checkbox: false,
            enabledEdit: true,
            allowUnSelectRow: true,
            alternatingRow: false,
            rownumbers: true,
            enabledSort: false,
            usePagerOnLessPagesize: false,
        });
        rlPsnGrid.setHeight(200);
    }


    //获取操作列
    function getOptColumn() {
        var column = {
            display: '操作',
            isSort: false,
            width: 150,
            align: 'left',
            render: function (rowdata, rowindex, value) {
                var h = "";
                if(rowdata.isDefault!=1){
                    h += '<a class="sq-button-hasicon" href="javascript:removeBtn(';
                    h += "'" + rowdata.id + "'";
                    h += ')"><i class="sqBtnIco_7"></i>删除</a>'
                 }
                return h;
            }
        }
        return column;
    }

    function removeBtn() {
        var selectedRows = rlPsnGrid.getSelectedRows();
        if (selectedRows.length != 1) {
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warring"});
            return;
        }
        $.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
            if (flag == false) return;
            if (selectedRows[0].id) {
                //删除数据
                var _ids = [];
                for (var index in selectedRows) {
                    _ids.push(selectedRows[index].id);
                }
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: {ids: JSON.stringify(_ids)},
                    url: '<%=path%>/project/prjLnkCompRlPsn/removeByIds.do',
                    success: function (msg) {
                        if (msg.success == 1) {
                            rlPsnGrid.deleteSelectedRow();
                            UIUtils.alertSuccess(msg.info);
                        } else {
                            UIUtils.alertError(msg.info);
                        }
                    }
                });

            } else {
                rlPsnGrid.deleteSelectedRow();
            }
        });
    }

    function addBtn() {
        //添加联系人信息
        var manager = $("#ligergrid_psn").ligerGetGridManager();
        manager.addRow({
            rlNm: '',
            rlTypCd: '',
            certTypCd: '',
            certNo: '',
            tel: '',
            rlRem: '',
        });
    }



  //对比ligerGrid编辑前后的Data
    //@param gridID <字符串> - ligerGrid id
    //@param fields [数组<字符串>] - 要对比的列的字段
    //@param count <数字>可选 - 参与对比的前几行
    //返回值：<Boolean> 如果对比结果一样，返回true，否者返回false
    //注：grid 加载完(onAfterShowData)后 必须缓存数据到'CACHED_DATA'这个属性上 ！！！
    function compareGridData(gridID, fields, count) {
        var grid = liger.get(gridID),
            cachedData = count ? grid.CACHED_DATA[grid.options.root].slice(0,count) : grid.CACHED_DATA[grid.options.root],
            currentData = count ? grid.getData().slice(0,count) : grid.getData(),
            cachedData_f = _filterData(cachedData),
            currentData_f = _filterData(currentData);
        return JSON.stringify(cachedData_f) === JSON.stringify(currentData_f)
        function _filterData(dataArr) {
            var newData = [];
            $(dataArr).each(function(index, rowData) {
                var newRow = {};
                for (var i = 0; i < fields.length; i++) {
                    var key = fields[i];
                    newRow[key] = rowData[key];
                }
                newData.push(newRow);
            });
            return newData;
        }
    };



    //对比ligerForm编辑前后的值
    //@param formID - <字符串> - ligerForm ID
    //@param fields [数组<字符串>]可选 - 只对比指定的字段
    //返回值：<Boolean> 如果对比结果一样，返回true，否者返回false
    //注：ligerForm 实例化完(onAfterSetFields)后 必须缓存数据到'CACHED_INIT_VALUES'这个属性上 ！！！
    function compareFormValues(formID, fields) {
        var _ligerForm = liger.get(formID),
            _CACHED_INIT_VALUES = _ligerForm.CACHED_INIT_VALUES,
            _CHANGED_VALUES = getFormValues(formID),
            _fields = Object.keys(_CACHED_INIT_VALUES);
        if (!fields) {
            return JSON.stringify(_CACHED_INIT_VALUES) === JSON.stringify(_CHANGED_VALUES)
        }
        // 以下是对比指定字段
        var compareResult = true;
        for (var i = 0; i < fields.length; i++) {
            var key = fields[i],
                _old = _CACHED_INIT_VALUES[key],
                _new = _CHANGED_VALUES[key];
            if (JSON.stringify(_old) != JSON.stringify(_new)) {
                compareResult = false;
                break;
            }
        }
        return compareResult;
    }
    // 获取所有表单元素的值，键值对的格式返回
    //@param fields - [数组<字符串>] - 1: 表单元素的name（id），只返回指定字段
    //@param fields - <字符串>       - 2: ligerForm ID， 返回所有字段的值
    function getFormValues(fields) {
        if (fields && typeof fields === 'string') {
            fields = liger.get(fields).autoEditors.map(function(v){return v.name})
        }
        return _filterFields();
        function _filterFields() {
            var newValues = {};
            $(fields).each(function(index, fieldID) {
                var _editor = liger.get(fieldID),
                    _editorValue = _editor ? _editor.getValue() : $('[name='+fieldID+']').val();
                newValues[fieldID] = _editorValue;
            });
            return newValues;
        }
    }

</script>
</body>
</html>
